/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 苏李涛
 * Date: 2024-05-17
 * Time: 19:00
 */
import demo1.*;
public class Test {
    public static void main(String[] args) {
        //向下转型,注意不是所有向上转型都会成功
        Animal animal = new Dog("wangcai", 2);
        Dog dog = (Dog) animal;
        dog.eat();


        Animal animal2 = new Dog("wangcai", 2);
        if (animal2 instanceof cat) {
            cat cat = (cat) animal2;
            cat.voice();
        } else {
            System.out.println("animal2 instanceof cat is not");
        }
    }
}
